import request from '@/config/axios'
import type { MetaData } from './types'

export const getMetaListApi = (params: any): Promise<IResponse> => {
    const queryParams = params.queryParams ? params.queryParams : {}
    if (params.queryParams) {
        delete params.queryParams
    }
    Object.assign(params, queryParams)
    return request.get({url: '/balance/meta/page', params})
}

export const saveOrUpdateMetaApi = (data: Partial<MetaData>, isUpdate = false): Promise<IResponse> => {
    if(isUpdate) {
        return request.post({url: '/balance/meta/edit', data})
    }else {
        return request.post({url: '/balance/meta/save', data})
    }
}

export const getMetaDetailApi = (data: Partial<MetaData>): Promise<IResponse<MetaData>> => {
    return request.get({url: '/balance/meta/detail', params: {data}})
}

export const delMetaListApi = (data: Partial<MetaData>[]): Promise<IResponse> => {
    return request.post({url: '/balance/meta/delete', data})
}
